<?php
include 'conn_mysql.php';

			
?>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, maximum-scale=1, user-scalable=no">
    <title>驴行天下</title>
    <link href="bootstrap.min.css" rel="stylesheet">
    <link href="style.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/jquery.min182.js"></script>
	<script language="javascript" src="js/jquery.form.js"></script>
	<script language="javascript" src="js/json.parse.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>

	<?php
		//查看订单是否已取消或已支付

		$sql="select id_self,is_zhifu from main_user where id_self='$id_main' ";
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query)){
			$this_id_self=$row['id_self'];
			$is_zhifu=$row['is_zhifu'];
			
		}
		if(!$this_id_self)
		{
			echo "<SCRIPT>alert('订单不存在');window.history.go(-1);</SCRIPT>";
			exit;
		}

		if($is_zhifu>0)
		{
			echo "<SCRIPT>alert('订单已支付或已取消无法选择游客');window.history.go(-1);</SCRIPT>";
			exit;
		}
		
		//购买人
		$sql="select real_name,shenfen_ID,mobile_phone from ecs_users where user_id='$user_id' ";
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query)){
			$real_name=$row['real_name'];
			$shenfen_ID=$row['shenfen_ID'];
			$mobile_phone=$row['mobile_phone'];
		}
		
		
		$sql="select id_fu from fu_user where id='$id_main' and idcode='$shenfen_ID' ";
		$query = mysql_query($sql);
		while($row = mysql_fetch_array($query)){
			$user_id_fu=$row['id_fu'];
		}

	?>
<!--header-->
<div class="header_title">
	<!--<p>【贵州精华】2016全年贵州：西江千户苗寨-朗德上寨-荔波小七孔-黄果树瀑布-青岩古镇，奇山秀水、苗家风情之旅6日团</p>-->
	<p><?php echo $biaoti;?></p><!--旅游项目标题-->
</div>
<!--plate-->
<div class="plate">
	<h1>选择游客</h1>
    <div class="plate_line">
        <div class="plate_line_choose">
        <form method="post" action="getmessage_all.php?bigtype=21">
        	<label>
                   <input type="checkbox"  value="<?php echo $shenfen_ID; ?>" name="idcode[]"  <?php if($user_id_fu){ ?> checked <?php } ?> > <p><?php echo $real_name; ?></p>
            </label>
            <?php
			        //所有对应不重复的陪同人员
					$sql="select  DISTINCT name,phone,idcode from fu_user where user_id='$user_id' and idcode!='$shenfen_ID' and idcode!=''  order by id_fu ";//获取所有user对应的陪同用户
					$query = mysql_query($sql);		
					$main_user=array();
					while($row = mysql_fetch_array($query)){
						
						$length=count($main_user);
						$row['is_chose']=0;
						$main_user[$length]=$row;
						
						
						//已选择的陪同人员
						$idcode=$row['idcode'];
						$find_sql="select id_fu,name from fu_user where id='$id_main' and idcode='$idcode' ";
						$find_query = mysql_query($find_sql);
						
						while($find_row= mysql_fetch_array($find_query)){
						    $main_user[$length]['is_chose']=1;
							break;
						}
						
					}

				
					
			?>
            <?php
			 foreach($main_user as $key_fu=>$value_fu)	
			 {				 
			?>
                 <label>
                     <input type="checkbox"    name="idcode[]"value="<?php echo $value_fu['idcode']; ?>" <?php if($value_fu['is_chose']){ ?> checked <?php } ?>  >
                     <p><?php echo $value_fu['name']; ?></p>
                 </label>
	
			  <?php 
			     } 
			  ?>

        </div>
    </div>
    
</div>
<input type="hidden" name="id_main" value="<?php echo $id_main; ?>">
<?php if(strlen($main_user[0]['is_chose'])==0){?>
	<a class="button" style="margin-bottom:10px"><input type="submit" value="添加游客"></a>
<?php }else{?>
	<a class="button" style="margin-bottom:10px" ><input type="submit" value="修改游客"></a>
<?php } ?>	

</form>
</body>

</html>
